<?php

namespace User\Form;

use User\Model\Entity\ModuleSettingsInterface;
use Zend\Form\Form;
use Zend\InputFilter\InputFilter;
use Zend\Stdlib\Hydrator\ClassMethods as ClassMethodsHydrator;

class RegisterForm extends Form {
    public function __construct(ModuleSettingsInterface $moduleSettings) {
    	parent::__construct('user_form');
        $this->setAttribute('method', 'post')
        	 ->setAttribute('class', 'form-horizontal')
             ->setHydrator(new ClassMethodsHydrator(false))
             ->setInputFilter(new InputFilter());

        $this->add(array(
            'type' => 'User\Form\Fieldset\RegisterFieldset',
            'options' => array(
                'use_as_base_fieldset' => true,
            )
        ));

        if($moduleSettings->getRegistrationUseFormCaptcha()) {
	        $this->add(array(
	        	'type' => 'Zend\Form\Element\Captcha',
	            'name' => 'captcha',
	        	'attributes' => array(
		        	'class' => 'form-control captcha',
	            ),
	            'options' => array(
	                'label' => 'Captcha',
	        		'label_attributes' => array( 
	            		'class' => 'col-lg-2 control-label',
	        		),
	            	'captcha' => new \Zend\Captcha\Image($moduleSettings->getFormCaptchaOptions()),
	        	),
	    	));
        }
    	
        $this->add(array(
        	'type' => 'Zend\Form\Element\Submit',
            'name' => 'submit',
            'attributes' => array(
        		'class' => 'btn btn-default',
                'value' => 'Register'
            )
        ));
    }
}